<template>
  <div class="col over-auto">
    <common-table :tableHeight="'calc(100% - 70px)'" v-loading="tableLoading" show-index show-check-box :columns="columns"
      :list="list">
    </common-table>
    <pagination class="pagination" :total="count" :page.sync="page.pageIndex" :limit.sync="page.pageSize"
      @pagination="pagination" />
  </div>
</template>

<script>
import CommonTable from "@/components/newSystem/newTable/CommonTable.vue"

import { queryPageApplicationScenarios } from "@/api/showManage/index.js"
export default {
  components: {
    CommonTable
  },
  props: {
    deviceCode: String,
  },
  data () {
    return {
      columns: [
        {
          title: "场景名称",
          prop: "applicationName",
          align: "center",
        },
        {
          title: "系统已解决异常数量",
          prop: "sysSettleTotal",
          align: "center",
        },
        {
          title: "今日已解决异常数量",
          prop: "toDaySettleNum",
          align: "center"
        },
        {
          title: "系统异常总数",
          prop: "sysAbnormalTotal",
          align: "center"
        },{
          title: "今日异常数量",
          prop: "toDayAbnormalNum",
          align: "center"
        },
        {
          title: "告警时间",
          prop: "createTime",
          align: "center",
        }
      ],
      list: [],
      tableLoading: false,
      dialogVisible: false,
      page: {
        pageSize: 10,
        pageIndex: 1,
      },
      count: 0,
      warnCode: ''
    }
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created () {

  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted () {
    this.getTableList()
  },
  // 存放方法事件 - 会在数据变化时被调用
  methods: {
    pagination (pageItem) {
      this.getTableList(pageItem.page, pageItem.limit)
    },
    handleDetail (row) {
      this.warnCode = row.row.warnCode
      this.dialogVisible = true
    },
    closeDialog () {
      this.dialogVisible = false
    },
    async getTableList () {
      this.tableLoading = true
      const { status, success, object, message } = await queryPageApplicationScenarios({...this.page })
      if (status == 200) {
        this.count = object.count
        this.list = object.data
      }
      this.tableLoading = false
    }
  }
}
</script>
<style scoped lang="scss">
.pagination {
  display: flex;
  justify-content: flex-end;
}
</style>
